<!DOCTYPE html>
<html>
<head>
<?php echo $this->loadTemplate('share' . DS . 'meta.phtml'); ?>
<script src="<?php echo $this->pubUrl ?>share/js/jquery/jquery.validate.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo $this->skin_url?>frontend/js/min.js"></script>

<script>
function ajaxFunction(id,url)
{
    $.ajax({
       'url':url+'/id/'+id
    });
}
$(function(){
    $('.support').bind( "click",function(){
            ajaxFunction($(this).attr('rel'),'/article/comment/updateSupport');
            var span =  $(this).children('span');
            span.html(parseInt(span.html())+1);
            $(this).unbind('click').removeClass().next('a').unbind('click').removeClass();
    })
    $('.opposition').bind('click',function(){
        ajaxFunction($(this).attr('rel'),'/article/comment/updateOpposition');
        var span =  $(this).children('span');
            span.html(parseInt(span.html())+1);
            $(this).unbind('click').removeClass().prev('a').unbind('click').removeClass();
    })
 })
 
</script>
</head>
<body>
<?php echo $this->loadTemplate('share' . DS . 'header.phtml'); ?>
<?php echo $this->loadBlock('share_navigation') ?>
<div class ="public_width comment">
    <div class="list_cont">
		<h1><?php echo $this->content->getTitle()?></h1>
    <?php foreach($this->comments as $comment):?>
        <dl>
            <dt><span>发表于<?php
                $second = strtotime(date('Y-m-d H:i:s')) - strtotime($comment->getTime());
                if(($second/3600/24)>1){echo (int)($second/3600/24).'天之前';}
                else if(($second/3600)>1){echo (int)($second/3600).'小时之前';}
                else if(($second/60)>1){echo (int)($second/60).'分钟之前';}
                else {echo (int)($second+1).'秒之前';}
            ?>
            </span><?php echo $comment->getAccount();?>:</dt>
            <dd><?php echo $comment->getDetail();?></dd>
         </dl>
         <ul>
                <a class="support" rel="<?php echo $comment->getId()?>">支持(<span><?php echo $comment->getSupport()?></span>)</a>
                <a class="opposition" rel="<?php echo $comment->getId()?>">反对(<span><?php echo $comment->getOpposition()?></span>)</a>
         </ul>
    <?php endforeach;?>
    </div>
    <?php echo $this->pagination->toHtml() ?>
    <div class="message-container">
        <?php echo  $this->loadTemplate('share' . DS . 'message.phtml'); ;?>
    </div>
    <?php echo $this->loadTemplate('share' . DS . 'commentform.phtml'); ?>
</div>
<?php echo $this->loadTemplate('share'.DS.'footer.phtml')?>
<body>
</html>